package Service;

import Dao.CreditCardDao;
import Pojo.CreditCard;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class CreditCardService {
    private final CreditCardDao creditCardDao = new CreditCardDao();

    public int insertCreditCardByUserId(String cardNumId,
                                        String cardPrice,
                                        String cardTime,
                                        String bankId,
                                        int userId) throws SQLException {
        return creditCardDao.insertCreditCardByUserId(cardNumId, cardPrice, cardTime, bankId, userId);
    }

    public List<Map<String, Object>> getCreditCardNoRePayByUserIdAndIndex(int userId, String cardNum, int pageIndex) throws SQLException {
        return creditCardDao.getCreditCardNoRePayByUserIdAndIndex(userId, cardNum, pageIndex);
    }

    public int getCreditCardNoRePayByUserIdAndIndex(int userId, String cardNum) throws SQLException {
        return creditCardDao.getCreditCardNoRePayByUserIdAndIndex(userId, cardNum);
    }

    public int updateCardStateByUserIdAndCardId(int userId, String cardId) throws SQLException {
        return creditCardDao.updateCardStateByUserIdAndCardId(userId, cardId);
    }

    public List<Map<String, Object>> getManagerCardBySeletive(int userId,
                                                              String minTime,
                                                              String maxTime,
                                                              String bankId,
                                                              String isPay,
                                                              String search,
                                                              int pageIndex) throws SQLException {
        return creditCardDao.getManagerCardBySeletive(userId, minTime, maxTime, bankId, isPay, search, pageIndex);
    }

    public int getManagerCardCountBySeletive(int userId,
                                             String minTime,
                                             String maxTime,
                                             String bankId,
                                             String isPay,
                                             String search) throws SQLException {
        return creditCardDao.getManagerCardCountBySeletive(userId, minTime, maxTime, bankId, isPay, search);
    }

    public Map<String, Object> getCreditCardByUserAndId(int userId, String cardId) throws SQLException {
        return creditCardDao.getCreditCardByUserAndId(userId, cardId);
    }

    public int updateCreditCardMsgByUserIDAndCardId(
            String cardPrice,
            String cardTime,
            String cardState,
            String bankId,
            int userId,
            String cardId) throws SQLException {
        return creditCardDao.updateCreditCardMsgByUserIDAndCardId(cardPrice, cardTime, cardState, bankId, userId, cardId);
    }

    public int deleteUserCreditCardById(int userId, String cardId) throws SQLException {
        return creditCardDao.deleteUserCreditCardById(userId, cardId);
    }

    public List<Map<String, Object>> getCreditCardAllIsAdmin(String minTime,
                                                             String maxTime,
                                                             String bankId,
                                                             String isPay,
                                                             String searchCon,
                                                             String search,
                                                             int pageIndex) throws SQLException {
        return creditCardDao.getCreditCardAllIsAdmin(minTime, maxTime, bankId, isPay, searchCon, search, pageIndex);
    }

    public int getCreditCardAllCountIsAdmin(String minTime,
                                            String maxTime,
                                            String bankId,
                                            String isPay,
                                            String searchCon,
                                            String search) throws SQLException {
        return creditCardDao.getCreditCardAllCountIsAdmin(minTime, maxTime, bankId, isPay, searchCon, search);
    }
}
